/**
 * File: ResultCollector.java
 * Created by: mhaimel
 * Created on: 3 Jul 2009
 * CVS:  $Id: ResultCollector.java,v 1.1 2009/08/05 15:16:11 mhaimel Exp $
 */
package uk.ac.ebi.curtain.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import uk.ac.ebi.curtain.management.IInterceptor;
import uk.ac.ebi.curtain.management.InterceptorInfo;

/**
 * @author mhaimel
 *
 */
public class ResultCollector implements IInterceptor<Serializable> {
	private List<Serializable> resultList = new ArrayList<Serializable>();
	private boolean isFinished = false;

	public void handle(Serializable input, InterceptorInfo info) {
		resultList.add(input);
	}

	public void shutDown(boolean force, InterceptorInfo info) {
		isFinished = true;
	}
	
	@SuppressWarnings("unchecked")
	public <T> List<T> getResultList() {
		return (List<T>) resultList;
	}
	
	public boolean isFinished() {
		return isFinished;
	}
	
}
